﻿using System;
using System.Collections.Generic;
using tour.szhome.common;
using TOUR.SZHOME.DAL;
using TOUR.SZHOME.Entity;
namespace TOUR.SZHOME.BLL
{
    /// <summary>
    /// 数据表Album的业务逻辑类
    /// </summary>
    public class AlbumBLL
    {
        /// <summary>
        /// 获取列表 -- 分页
        /// </summary>
        /// <param name="pid"></param>
        /// <param name="pageSet"></param>
        /// <returns></returns>
        public List<AlbumEntity> GetList(PageSet pageSet)
        {
            string where = " 1 = 1 ";
            pageSet.RecordCount = AlbumDAL.SearchCount(where);
            pageSet.PageCount = (int)Math.Ceiling(pageSet.RecordCount / (pageSet.PageSize * 1.0));
            return AlbumDAL.Search(where, "[Order]", (pageSet.PageIndex - 1) * pageSet.PageSize, pageSet.PageSize);
        }

        /// <summary>
        /// 根据ID获取对象实体
        /// </summary>
        /// <param name="lid"></param>
        /// <returns></returns>
        public AlbumEntity GetByID(int lid)
        {
            return AlbumDAL.GetByID(lid);
        }

        /// <summary>
        /// 根据ID删除对象
        /// </summary>
        /// <param name="nid"></param>
        /// <returns></returns>
        public bool DelByID(int nid)
        {
            return AlbumDAL.Delete(nid);
        }

        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Edit(AlbumEntity model)
        {
            if (model.ID > 0)
            {
                return AlbumDAL.Update(model);
            }
            else
            {
                return AlbumDAL.Insert(model);
            }
        }

        /// <summary>
        /// 修改排序
        /// </summary>
        /// <param name="link_id"></param>
        /// <param name="link_num1"></param>
        /// <param name="link_id2"></param>
        /// <param name="link_num2"></param>
        /// <returns></returns>
        public bool OrderUpdate(long link_id, int link_num1, long link_id2, int link_num2)
        {
            return AlbumDAL.OrderUpdate(link_id, link_num1, link_id2, link_num2);
        }
    }
}
